BlackBerry - Convert EncodedImage to byte []

Posted by user324884 on Stack Overflow See other posts from Stack Overflow or by user324884
Published on 2010-04-26T10:27:14Z Indexed on 2010/04/26 11:53 UTC
Read the original article Hit count: 192

I am using below code where i don't want to use JPEGEncodedImage.encode because it increases the size. So I need to directly convert from EncodedImage to byte array.

FileConnection fc= (FileConnection)Connector.open(name);

is=fc.openInputStream();

byte[] ReimgData = IOUtilities.streamToBytes(is);

EncodedImage encode_image = 
    EncodedImage.createEncodedImage(ReimgData, 0, (int)fc.fileSize());

encode_image = sizeImage(encode_image, (int)maxWidth,(int)maxHeight);

JPEGEncodedImage encoder=JPEGEncodedImage.encode(encode_image.getBitmap(),50);

ReimgData=encoder.getData();

is.read(ReimgData);

HttpMultipartRequest(
                content[0],
                content[1],
                content[2],
                params,
                "image",txtfile.getText(), "image/jpeg", ReimgData
            );

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about image